package com.bestcem.xm.member.entity.pojo;

import com.bestcem.xm.member.entity.mysql.DisplayRangeEntity;
import com.bestcem.xm.member.enums.DisplayRangeTypeEnum;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Date;

/**
 * 联系人联系信息展示范围数据实体
 *
 * @author dc.wang <dc.wang@idiaoyan.com>
 * @version V1.0
 * @date 2021/7/7
 */
@Getter
@Setter
@ToString
public class DisplayRangeDO {

    private String displayId;

    /**
     * 组织标识
     */
    private String orgId;

    /**
     * 联系人类型
     */
    private Integer memberType;

    /**
     * 联系方式(手机和邮箱)可见性类型
     *
     * @see DisplayRangeTypeEnum
     */
    private Integer type;

    /**
     * 可见管理员角色标识
     * "id1,id2,..."
     */
    private String roleIds;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    public static DisplayRangeDO toDo(DisplayRangeEntity entity) {
        if (entity == null) {
            return null;
        }

        DisplayRangeDO displayRangeDo = new DisplayRangeDO();
        displayRangeDo.setCreateTime(entity.getCreateTime());
        displayRangeDo.setDisplayId(entity.getDisplayId());
        displayRangeDo.setMemberType(entity.getMemberType());
        displayRangeDo.setOrgId(entity.getOrgId());
        displayRangeDo.setRoleIds(entity.getRoleIds());
        displayRangeDo.setType(entity.getType());
        displayRangeDo.setUpdateTime(entity.getUpdateTime());
        return displayRangeDo;
    }

    public static DisplayRangeEntity toEntity(DisplayRangeDO displayRangeDo) {
        if (displayRangeDo == null) {
            return null;
        }

        DisplayRangeEntity displayRangeEntity = new DisplayRangeEntity();
        displayRangeEntity.setCreateTime(displayRangeDo.getCreateTime());
        displayRangeEntity.setDisplayId(displayRangeDo.getDisplayId());
        displayRangeEntity.setMemberType(displayRangeDo.getMemberType());
        displayRangeEntity.setOrgId(displayRangeDo.getOrgId());
        displayRangeEntity.setRoleIds(displayRangeDo.getRoleIds());
        displayRangeEntity.setType(displayRangeDo.getType());
        displayRangeEntity.setUpdateTime(displayRangeDo.getUpdateTime());
        return displayRangeEntity;
    }
}
